﻿//(local)
//devsvr

using System;
using System.Data;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Word;

public partial class SqlChar : Form
{
    private StringBuilder sb;

    private OpenFileDialog openFileDialog2;

    public SqlChar()
    {
        InitializeComponent();

        sb = new StringBuilder();
        openFileDialog2 = new OpenFileDialog();
        openFileDialog2.RestoreDirectory = true;
    }

    /// <summary>
    /// 测试
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void buttonTestConect_Click(object sender, EventArgs e)
    {
        try
        {
            if (this.textBoxServer.Text == "") { MessageBox.Show("非空"); return; }
            if (this.textBoxDataBase.Text == "") { MessageBox.Show("非空"); return; }

            string datasource = this.textBoxServer.Text;
            string database = this.textBoxDataBase.Text;

            Tsql.boolSql = true;
            Tsql.database = database;
            Tsql.datasource = datasource;
            Tsql.uid = this.textBoxUid.Text;
            Tsql.pwd = this.textBoxPass.Text;

            Tsql t = new Tsql();
            if (t.TestSqlConnstring())
            {
                MessageBox.Show("成功！");
            }
            else
            {
                MessageBox.Show("失败！");
                this.dataGridViewTable.DataSource = null;
                return;
            }

            this.dataGridViewTable.DataSource = t.getNameSql();
        }
        catch (Exception ex)
        {
            //Log.Console.WriteLine("Error=============================");
            //Log.Console.WriteLine("Message:" + ex.Message);
            //Log.Console.WriteLine("ENDError=============================");
        }
    }

    /// <summary>
    /// 生成怎删改查字符串
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void buttonOpration_Click(object sender, EventArgs e)
    {
        Tsql t = new Tsql();
        string tableName = this.textBoxTableName.Text;

        StringBuilder sb;
        sb = new StringBuilder();

        //string sql1 = "\"select ";
        //string sql = "\"UPDATE " + tableName + " SET ";

        string strHash = "";

        DataTable dataTable1 = t.GetDataSourceSql("select   a.[name] as lieming,b.[name] as leixing    from   syscolumns a,systypes b  where   a.id=object_id('" + tableName + "') and a.xtype=b.xtype and    b.[name]<>'sysname'");
        DataRow dr1;

        for (int i = 0; i < dataTable1.Rows.Count; i++)
        {
            dr1 = dataTable1.Rows[i];
            //if (i == dataTable1.Rows.Count - 1)
            //{
            //    if (dr1["leixing"].ToString() == "int" || dr1["leixing"].ToString() == "numeric")
            //    {
            //        sql += "" + dr1["lieming"] + " = '\" + " + dr1["lieming"] + " + \"';\"";
            //    }
            //    else
            //    {
            //        sql += "" + dr1["lieming"] + " = \" + " + dr1["lieming"] + " + \";\"";
            //    }

            //    sql1 += dr1["lieming"] + " from " + tableName + "\";";
            //}
            //else
            //{
            //    if (dr1["leixing"].ToString() == "int" || dr1["leixing"].ToString() == "numeric")
            //    {
            //        sql += "" + dr1["lieming"] + " = \" + " + dr1["lieming"] + " + \",";
            //    }
            //    else
            //    {
            //        sql += "" + dr1["lieming"] + " = '\" + " + dr1["lieming"] + " + \"',";
            //    }

            //    sql1 += dr1["lieming"] + ",";
            //}
            strHash += "hashtableColumnName.Add(\"" + dr1["lieming"].ToString().ToUpper() + "\", this." + dr1["lieming"].ToString() + ");\n";
        }

        //sb.Append(sql1 + "\n\n");
        //sb.Append(sql + "\n");

        sb.Append(strHash + "\n");
        this.richTextBox2.Text = sb.ToString();
    }

    /// <summary>
    /// 生成bean文件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void buttonBean_Click(object sender, EventArgs e)
    {
        Tsql t = new Tsql();
        string tableName = this.textBox2.Text;

        StringBuilder strTrans;
        strTrans = new StringBuilder();

        //*********************************************************
        //
        //*********************************************************
        string strnamespace = this.textBoxnamespace.Text;
        string strclass = this.textBoxclass.Text;

        strTrans.Append("using System;\n");
        strTrans.Append("using System.Collections.Generic;\n");
        strTrans.Append("using System.Text;\n");
        strTrans.Append("\n");
        strTrans.Append("namespace " + strnamespace + "\n");
        strTrans.Append("{\n");
        strTrans.Append("    class " + strclass + "\n");
        strTrans.Append("    {\n");

        //*********************************************************
        //属性
        //*********************************************************
        #region 属性
        strTrans.Append("#region 属性");
        strTrans.Append("    \n");

        DataTable dataTable1 = t.GetDataSourceSql("select   a.[name] as lieming,b.[name] as leixing    from   syscolumns a,systypes b  where   a.id=object_id('" + tableName + "') and a.xtype=b.xtype and    b.[name]<>'sysname'");
        DataRow dr1;

        for (int i = 0; i < dataTable1.Rows.Count; i++)
        {
            dr1 = dataTable1.Rows[i];

            string strLeixing = dr1["lieming"].ToString().Substring(0, 1);
            string strLieming = dr1["lieming"].ToString();
            string strLiemingUp = dr1["lieming"].ToString().Substring(0, 1).ToUpper() + dr1["lieming"].ToString().Substring(1, dr1["lieming"].ToString().Length - 1);

            switch (strLeixing)
            {
                case "i":
                    strTrans.Append("private int " + strLieming + ";\n");
                    strTrans.Append("    public int " + strLiemingUp + "\n");
                    strTrans.Append("    {\n");
                    strTrans.Append("        set\n");
                    strTrans.Append("        {\n");
                    strTrans.Append("            " + strLieming + " = value;\n");
                    strTrans.Append("        }\n");
                    strTrans.Append("        get\n");
                    strTrans.Append("        {\n");
                    strTrans.Append("            return " + strLieming + ";\n");
                    strTrans.Append("        }\n");
                    strTrans.Append("    }\n");

                    break;

                case "s":
                    strTrans.Append("private string " + strLieming + ";\n");
                    strTrans.Append("    public string " + strLiemingUp + "\n");
                    strTrans.Append("    {\n");
                    strTrans.Append("        set\n");
                    strTrans.Append("        {\n");
                    strTrans.Append("            " + strLieming + " = value;\n");
                    strTrans.Append("        }\n");
                    strTrans.Append("        get\n");
                    strTrans.Append("        {\n");
                    strTrans.Append("            return " + strLieming + ";\n");
                    strTrans.Append("        }\n");
                    strTrans.Append("    }\n");

                    break;

                case "f":
                    strTrans.Append("private float " + strLieming + ";\n");
                    strTrans.Append("    public float " + strLiemingUp + "\n");
                    strTrans.Append("    {\n");
                    strTrans.Append("        set\n");
                    strTrans.Append("        {\n");
                    strTrans.Append("            " + strLieming + " = value;\n");
                    strTrans.Append("        }\n");
                    strTrans.Append("        get\n");
                    strTrans.Append("        {\n");
                    strTrans.Append("            return " + strLieming + ";\n");
                    strTrans.Append("        }\n");
                    strTrans.Append("    }\n");

                    break;

                case "b":
                    strTrans.Append("private bool " + strLieming + ";\n");
                    strTrans.Append("    public bool " + strLiemingUp + "\n");
                    strTrans.Append("    {\n");
                    strTrans.Append("        set\n");
                    strTrans.Append("        {\n");
                    strTrans.Append("            " + strLieming + " = value;\n");
                    strTrans.Append("        }\n");
                    strTrans.Append("        get\n");
                    strTrans.Append("        {\n");
                    strTrans.Append("            return " + strLieming + ";\n");
                    strTrans.Append("        }\n");
                    strTrans.Append("    }\n");

                    break;
            }
        }
        strTrans.Append("#endregion");
        #endregion 属性

        //*********************************************************
        //方法
        //*********************************************************
        strTrans.Append("    \n");
        strTrans.Append("    \n");
        strTrans.Append("#region 方法");
        strTrans.Append("    \n");

        //*********************************************************
        //查询
        //*********************************************************
        #region
        strTrans.Append("    public DataTable Select()\n");
        strTrans.Append("    {\n");
        strTrans.Append("        string strSql = \"select * from " + tableName + "\";\n");
        strTrans.Append("        return Sql_zr.ExecuteDataTable(strSql);\n");
        strTrans.Append("    }\n");

        //*********************************************************
        //查询对应键
        //*********************************************************
        if (textBoxId.Text.Trim() == "")
        {
            MessageBox.Show("没对应键 没有对应查询！");
        }
        else
        {
            string[] strRequire = textBoxRequire.Text.Split(',');

            //*********************************************************
            //生成对应字段 增删改
            //*********************************************************
            foreach (string strTemp in strRequire)
            {
                if (strTemp.Substring(0, 1) == "i" || strTemp.Substring(0, 1) == "f")
                {
                    //*********************************************************
                    //特定查
                    //*********************************************************
                    strTrans.Append("public DataTable Select" + strTemp + "(string strSelect)\n");
                    strTrans.Append("    {\n");

                    strTrans.Append("        string strSql = \"select \" + strSelect + \" from " + tableName + " where " + strTemp + "=\"+" + strTemp + "+\"\";\n");

                    strTrans.Append("        return Sql_zr.ExecuteDataTable(strSql);\n");
                    strTrans.Append("    }\n");

                    //*********************************************************
                    //一般查
                    //*********************************************************
                    strTrans.Append("public DataTable Select" + strTemp + "()\n");
                    strTrans.Append("    {\n");

                    strTrans.Append("        string strSql = \"select * from " + tableName + " where " + strTemp + "=\"+" + strTemp + "+\"\";\n");

                    strTrans.Append("        return Sql_zr.ExecuteDataTable(strSql);\n");
                    strTrans.Append("    }\n");

                    //*********************************************************
                    //修改
                    //*********************************************************
                }
                else
                {
                    //*********************************************************
                    //特定查
                    //*********************************************************
                    strTrans.Append("public DataTable Select" + strTemp + "(string strSelect)\n");
                    strTrans.Append("        string strSql = \"select \" + strSelect + \" from " + tableName + " where " + strTemp + "='\"+" + strTemp + "+\"'\";\n");

                    strTrans.Append("        return Sql_zr.ExecuteDataTable(strSql);\n");
                    strTrans.Append("    }\n");

                    //*********************************************************
                    //一般查
                    //*********************************************************
                    strTrans.Append("public DataTable Select" + strTemp + "()\n");
                    strTrans.Append("    {\n");

                    strTrans.Append("        string strSql = \"select * from " + tableName + " where " + strTemp + "='\"+" + strTemp + "+\"'\";\n");

                    strTrans.Append("        return Sql_zr.ExecuteDataTable(strSql);\n");
                    strTrans.Append("    }\n");
                }
            }
        }

        //*********************************************************
        //～～～查询对应键
        //*********************************************************
        #endregion
        //*********************************************************
        //~~~查询
        //*********************************************************

        string[] strMajor = new string[] { "" };
        //*********************************************************
        //插入
        //*********************************************************
        #region 插入

        if (textBoxInsert.Text.Trim() != "")
        {
            strMajor = textBoxInsert.Text.Trim().Split(',');
        }

        string strColumn = "(";
        string strValue = "(";

        string strInsert = "\"insert into " + tableName + " ";

        for (int i = 0; i < dataTable1.Rows.Count; i++)
        {
            dr1 = dataTable1.Rows[i];

            bool boolExit = false;
            foreach (string strTemp in strMajor)
            {
                if (dr1["lieming"].ToString() == strTemp)
                {
                    boolExit = true;
                    break;
                }
            }
            if (boolExit)
            {
                continue;
            }

            //*********************************************************
            //最后一列
            //************************************
            if (i == dataTable1.Rows.Count - 1)
            {
                strColumn += dr1["lieming"];

                if (dr1["leixing"].ToString() == "int" || dr1["leixing"].ToString() == "numeric" || dr1["leixing"].ToString() == "decimal")
                {
                    strValue += " \" + " + dr1["lieming"] + " + \" ";
                }
                else
                {
                    strValue += "' \" + " + dr1["lieming"] + " + \" '";
                }
            }
            //*********************************************************
            //前面列
            //************************************
            else
            {
                strColumn += dr1["lieming"] + ",";

                if (dr1["leixing"].ToString() == "int" || dr1["leixing"].ToString() == "numeric" || dr1["leixing"].ToString() == "decimal")
                {
                    strValue += " \" + " + dr1["lieming"] + " + \" ,";
                }
                else
                {
                    strValue += "' \" + " + dr1["lieming"] + " + \" ',";
                }
            }
        }

        strColumn += ")";
        strValue += ")";

        strInsert += strColumn;
        strInsert += " values ";
        strInsert += strValue + "\";";

        strTrans.Append(" public bool Insert()\n");
        strTrans.Append("    {\n");
        strTrans.Append("        string strSql = " + strInsert + "\n");
        strTrans.Append("        if (Sql_zr.ExecuteNonQuery(strSql) != 1)\n");
        strTrans.Append("        {\n");
        strTrans.Append("            return false;\n");
        strTrans.Append("        }\n");
        strTrans.Append("        else\n");
        strTrans.Append("        {\n");
        strTrans.Append("            return true;\n");
        strTrans.Append("        }\n");
        strTrans.Append("\n");
        strTrans.Append("    }\n");
        #endregion
        //*********************************************************
        //～～～插入
        //*********************************************************

        //*********************************************************
        //count
        //*********************************************************
        #region

        strMajor = textBoxCount.Text.Trim().Split(',');

        strTrans.Append("   public int Count()\n");
        strTrans.Append("    {\n");
        strTrans.Append("        string strSql = \"select count(*) from " + tableName + "\";\n");
        strTrans.Append("        return (int)Sql_zr.ExecuteScalar(strSql);\n");
        strTrans.Append("    }\n");

        foreach (string strTemp in strMajor)
        {
            strTrans.Append("public int Count" + strTemp + "()\n");
            strTrans.Append("    {\n");
            strTrans.Append("        string strSql = \"select count(*) from " + tableName + " where " + strTemp + "= \"+" + strTemp + "+\" \";\n");
            strTrans.Append("        return (int)Sql_zr.ExecuteScalar(strSql);\n");
            strTrans.Append("    }\n");
            strTrans.Append("\n");
        }
        #endregion
        //*********************************************************
        //~~~~count
        //*********************************************************

        //*********************************************************
        //修改
        //*********************************************************
        #region

        if (textBoxId.Text.Trim() == "")
        {
            MessageBox.Show("没主键 没有修改！");
        }
        else
        {
            strMajor = textBoxId.Text.Trim().Split(',');

            string sql = "\"UPDATE " + tableName + " SET ";
            foreach (string strTemp in strMajor)
            {
                if (strTemp.Substring(0, 1) == "i" || strTemp.Substring(0, 1) == "f")
                {
                    //*********************************************************
                    //
                    //*********************************************************
                    for (int i = 0; i < dataTable1.Rows.Count; i++)
                    {
                        dr1 = dataTable1.Rows[i];

                        if (strTemp == dr1["lieming"].ToString())
                        {
                            continue;
                        }

                        if (i == dataTable1.Rows.Count - 1)
                        {
                            if (dr1["leixing"].ToString() == "int" || dr1["leixing"].ToString() == "numeric" || dr1["leixing"].ToString() == "decimal")
                            {
                                sql += "" + dr1["lieming"] + " = \" + " + dr1["lieming"] + " + \" ";
                            }
                            else
                            {
                                sql += "" + dr1["lieming"] + " = '\" + " + dr1["lieming"] + " + \"' ";
                            }
                        }
                        else
                        {
                            if (dr1["leixing"].ToString() == "int" || dr1["leixing"].ToString() == "numeric" || dr1["leixing"].ToString() == "decimal")
                            {
                                sql += "" + dr1["lieming"] + " = \" + " + dr1["lieming"] + " + \",";
                            }
                            else
                            {
                                sql += "" + dr1["lieming"] + " = '\" + " + dr1["lieming"] + " + \"',";
                            }
                        }
                    }

                    sql += "  where " + strTemp + "=\"+" + strTemp + "+\"\";\n";

                    strTrans.Append("public int Update" + strTemp + "() \n");
                    strTrans.Append("    {\n");
                    strTrans.Append("        string strSql = " + sql + "\n");
                    strTrans.Append("        return Sql_zr.ExecuteNonQuery(strSql);\n");
                    strTrans.Append("    }\n");
                }
            }
        }
        #endregion
        //*********************************************************
        //~~修改
        //*********************************************************

        //*********************************************************
        //删除
        //*********************************************************
        #region
        if (textBoxDelete.Text.Trim() == "")
        {
            MessageBox.Show("没主键 没有删除！");
        }
        else
        {
            strMajor = textBoxDelete.Text.Trim().Split(',');

            foreach (string strTemp in strMajor)
            {
                string strDelete = "\"delete from " + tableName + " where ";
                strDelete += strTemp + "=\"+" + strTemp + "+\"\";\n";

                strTrans.Append(" public int Delete" + strTemp + "()\n");
                strTrans.Append("    {\n");
                strTrans.Append("        string strSql = " + strDelete + "\n");
                strTrans.Append("        return Sql_zr.ExecuteNonQuery(strSql);\n");
                strTrans.Append("    }\n");
            }
        }

        #endregion
        //*********************************************************
        //~~删除
        //*********************************************************

        //*********************************************************
        //结尾
        //*********************************************************
        strTrans.Append("#endregion");
        strTrans.Append("\n");
        strTrans.Append("}\n");
        strTrans.Append("}\n");

        this.richTextBoxBean.Text = strTrans.ToString();
    }

    /// <summary>
    /// 配置文件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void button6_Click(object sender, EventArgs e)
    {
        openFileDialog2.InitialDirectory = @"D:\Work\WebSite";

        openFileDialog2.Filter = "配置文件|*.config|All files (*.*)|*.*";

        if (openFileDialog2.ShowDialog() == DialogResult.OK)
        {
            this.textBoxFile.Text = openFileDialog2.FileName;
        }
    }

    private void SqlChar_Load(object sender, EventArgs e)
    {
    }

    /// <summary>
    /// 修改配置
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void button7_Click(object sender, EventArgs e)
    {
        if (textBoxStrCon.Text != "")
        {
            Changexml(textBoxStrCon.Text);
        }
    }

    //*********************************************************
    // 修改
    //*********************************************************
    private void Changexml(string key)
    {
        Encoding encode = System.Text.Encoding.UTF8;
        FileStream fileStream = new FileStream(this.textBoxFile.Text, FileMode.Open);
        StreamReader read = new StreamReader(fileStream, encode);
        string strTemp = read.ReadLine();

        string uid = "uid=.*?;|User ID=.*?;";
        string pwd = "pwd=.*?;|Password=.*?;";
        string DataSource = "Data Source=.*?;";
        string DataBase = "database=.*?;";

        string Txtuid = this.textBoxUid.Text;
        string Txtpwd = this.textBoxPass.Text;
        string TxtDataSource = this.textBoxServer.Text;
        string TxtDataBase = this.textBoxDataBase.Text;

        StringBuilder strTransmitString = new StringBuilder();

        while (strTemp != null)
        {
            if (strTemp.IndexOf(key) != -1)
            {
                if (strTemp.IndexOf("uid=") != -1)
                {
                    strTemp = change(strTemp, uid, "uid=" + Txtuid + ";");
                }
                else if (strTemp.IndexOf("User ID=") != -1)
                {
                    strTemp = change(strTemp, uid, "User ID=" + Txtuid + ";");
                }

                if (strTemp.IndexOf("pwd=") != -1)
                {
                    strTemp = change(strTemp, pwd, "pwd=" + Txtpwd + ";");
                }
                else if (strTemp.IndexOf("Password=") != -1)
                {
                    strTemp = change(strTemp, pwd, "Password=" + Txtpwd + ";");
                }

                strTemp = change(strTemp, DataSource, "Data Source=" + TxtDataSource + ";");
                strTemp = change(strTemp, DataBase, "database=" + TxtDataBase + ";");
            }

            strTransmitString.Append(strTemp + "\n");

            strTemp = read.ReadLine();
        }

        read.Close();
        fileStream.Close();

        fileStream = new FileStream(this.textBoxFile.Text, FileMode.Open);
        StreamWriter sw = new StreamWriter(fileStream, encode);
        sw.Write(strTransmitString.ToString());

        sw.Close();

        MessageBox.Show("修改成功！");
    }

    //*********************************************************
    // 修改
    //*********************************************************
    private string change(string strTemp, string regex, string replace)
    {
        string result = Regex.Replace(strTemp, regex,
         replace, RegexOptions.IgnoreCase);
        return result;
    }

    /// <summary>
    /// 读取配置
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void button1_Click(object sender, EventArgs e)
    {
        if (textBoxStrCon.Text != "")
        {
            Readxml(textBoxStrCon.Text);
        }
    }

    private void Readxml(string key)
    {
        if (this.textBoxFile.Text == "")
        {
            MessageBox.Show("选择配置文件");
            return;
        }

        Encoding encode = System.Text.Encoding.UTF8;
        FileCtrl.FileAccess(this.textBoxFile.Text);

        FileStream fileStream = new FileStream(this.textBoxFile.Text, FileMode.Open);
        StreamReader read = new StreamReader(fileStream, encode);
        string strTemp = read.ReadLine();

        string uid = "uid=.*?;|User ID=.*?;";
        string pwd = "pwd=.*?;|Password=.*?;";
        string DataSource = "(Data Source=).*?;";
        string DataBase = "database=.*?;";

        StringBuilder strTransmitString = new StringBuilder();

        while (strTemp != null)
        {
            if (strTemp.IndexOf(key) != -1)
            {
                this.textBoxUid.Text = Readxml(strTemp, uid);
                //if (this.textBoxUid.Text == "")
                //{
                //    uid = "User ID=.*?;";
                //    this.textBoxUid.Text = Readxml(strTemp, uid);
                //}

                this.textBoxPass.Text = Readxml(strTemp, pwd);
                //if (this.textBoxPass.Text == "")
                //{
                //    pwd = "Password=.*?;";
                //    this.textBoxPass.Text = Readxml(strTemp, pwd);
                //}

                this.textBoxServer.Text = Readxml(strTemp, DataSource);
                this.textBoxDataBase.Text = Readxml(strTemp, DataBase);

                if (textBoxDataBase.Text != "")
                {
                    return;
                }
            }

            strTransmitString.Append(strTemp + "\n\r");

            strTemp = read.ReadLine();
        }

        read.Close();
    }

    //*********************************************************
    // 取值
    //*********************************************************
    /// <summary>
    ///
    /// </summary>
    /// <param name="strTemp"></param>
    /// <param name="regex"></param>
    /// <returns></returns>
    private string Readxml(string strTemp, string regex)
    {
        string result = Regex.Match(strTemp, regex, RegexOptions.IgnoreCase).Value;

        try
        {
            result = result.Substring(result.IndexOf("=") + 1, result.IndexOf(";") - result.IndexOf("=") - 1);
        }
        catch (Exception e) { }

        return result;
    }

    private SqlBase.WordApp CurWordApp = null;

    /// <summary>
    /// 生成存储过程
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void button2_Click(object sender, EventArgs e)
    {
        Tsql t = new Tsql();

        string strSql = "select   [name],[id]   from   dbo.sysobjects   where   type='p'";

        DataTable dataTable1 = t.GetDataSourceSql(strSql);

        ///
        SqlBase.WordApp wordApp = new SqlBase.WordApp();
        CurWordApp = wordApp;
        wordApp.createDocument();

        ///
        DataRow dr1;
        for (int i = 0; i < dataTable1.Rows.Count; i++)
        {
            dr1 = dataTable1.Rows[i];

            InsertTitle(dr1["name"].ToString(), Style.One);

            strSql = "select text from dbo.syscomments where id=" + dr1["id"] + "";
            DataTable dataTable2 = t.GetDataSourceSql(strSql);
            string strTemp = "";

            DataRow dr2;
            for (int j = 0; j < dataTable2.Rows.Count; j++)
            {
                dr2 = dataTable2.Rows[j];

                strTemp += dr2["text"];
            }

            CurWordApp.insertText(strTemp);
        }
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="sourse"></param>
    /// <param name="Format"></param>
    private void InsertTitle(string sourse, string Format)
    {
        CurWordApp.insertTitle(sourse, Format);
    }

    private void InsertTitle(string sourse, string Format, WdColor wdColor)
    {
        CurWordApp.insertTitle(sourse, Format, wdColor);
    }

    public struct Style
    {
        //public static string One = "Heading 1";
        //public static string Two = "Heading 2";
        //public static string Tree = "Heading 3";
        //public static string Four = "Heading 4";
        //public static string Five = "Heading 5";

        public static string One = "标题 1";
        public static string Two = "标题 2";
        public static string Tree = "标题 3";
        public static string Four = "标题 4";
        public static string Five = "标题 5";
    }

    public struct Color
    {
        public static WdColor ColorClass = WdColor.wdColorDarkBlue;
        public static WdColor ColorEnum = WdColor.wdColorRose;
        public static WdColor ColorInterface = WdColor.wdColorDarkGreen;
        public static WdColor ColorStruct = WdColor.wdColorLightBlue;
        public static WdColor ColorDelegate = WdColor.wdColorRed;
        public static WdColor ColorEvent = WdColor.wdColorPink;

        public static WdColor ColorFunction = WdColor.wdColorRed;
    }
}